<%@ page contentType="text/html; charset=utf-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%request.setCharacterEncoding("utf-8");%>
<c:if test="${requestScope.index==null}">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link type="text/css" rel="stylesheet" href="css/style.css" />
<title>jsp+servlet+javabean guestbook</title>
</head>

<body>

	<c:import url="/index"></c:import>
	<div id="head">
		<h1>JSP+Servlet+JavaBean 留言本</h1>
	</div>
	<div id="nav">
		<div id="AdminLogin">
	    <c:if test="${sessionScope.admin==null}">
	    	<form id="login" name="login" method="post" action="Login">
	            <label>帐号：<input type="text" id="username" name="username" /></label>
	            <label>密码：<input type="password" id="password" name="password" /></label>
	            <label><input type="submit" value="登录" /></label>
	        </form> 
	    </c:if>
	    <c:if test="${sessionScope.admin!=null}">
	    	&nbsp;${sessionScope.admin}，欢迎您的到来！&nbsp;<a href='Login?act=logout'>退出登录</a> 
	    </c:if>   
	    </div>
	    <div id="postlink"><a href="post.jsp">发表留言</a></div>
	    <div id="homesearch">
	   	  <form id="search" name="search" method="get" action="Search">
	        	<label>留言搜索：<input type="text" id="q" name="q" /></label>
	            <label><input type="submit" value="搜索" /></label>
	      </form>
	    </div>
	</div>
	<div id="main">
		<div id="title">
	        <ul>
	            <li class="cid">编号</li>
	            <li class="title">标题</li>
	            <li class="click">点击</li>
	            <li class="user">用户</li>
	            <li class="act">操作</li>
	        </ul>
	    </div>
	<c:forEach var="ilist" items="${requestScope.index}">
			<div class="list">
				<ul>
					<li class="cid">${ilist.id}</li>
					<li class="title"><a href="view?id=${ilist.id}" target="_blank" title="post time:${ilist.posttime}">${ilist.title}</a></li>
					<li class="click">${ilist.hitsnum}</li>
					<li class="user">${ilist.user}</li>
					<c:if test="${sessionScope.admin==null}"><li class="act">删除</li></c:if>
					<c:if test="${sessionScope.admin!=null}"><li class="act"><a href="Do?id=${ilist.id}">删除</a></li></c:if>
				</ul>
			</div>
		</c:forEach>
		<div id="page">		
			总共<font color="#ff0000">${requestScope.allsize}</font>条 &nbsp;
			每页显示<font color="#ff0000">${requestScope.pagesize}</font>条 &nbsp;	
			共<font color="#ff0000">${requestScope.allpage}</font>页			
			当前第<font color="#ff0000">${requestScope.page}</font>页 &nbsp;
			
		<c:if test="${requestScope.page>1}">
			<a href='index.jsp'>首页</a>
			<a href='index.jsp?page=${requestScope.page-1}'>上页</a>
		</c:if>	
		<c:if test="${requestScope.page<requestScope.allpage}">
			<a href='index.jsp?page=${requestScope.page+1}'>下页</a>
			<a href='index.jsp?page=${requestScope.allpage}'>尾页</a>
		</c:if>	
		</div>
	</div>
	<div id="foot">
		power by diplodocus
	</div>
</body>
</html>
</c:if>